<?php
/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/4/18
 * Time: 上午9:45
 */

namespace App\Busi\Traits;


use App\Models\Banner;

Trait BannerTrait
{
    public function getBannerListById($tag_id,$platfrom){
        $where = [
            ["tag_id","=",$tag_id],
            ["flag","=",1]
        ];
        $field = ['open_type as type', 'title', 'poster', 'type_info as content'];
        $data = Banner::where($where)->wherein('platform',[0,$platfrom])->select($field)->orderBy('show_order','desc')->get();
        if($data->isEmpty()){
            return "";
        }
        foreach($data as &$item){
            $item['poster'] = config('admin.upload.host').$item['poster'];

        }
        return $data;

    }
}